package com.example.forjava.controller;

import com.example.forjava.annotation.LogAnnotation;
import com.example.forjava.annotation.PermissionAnnotation;
import com.example.forjava.util.GenericJsonResult;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
@RequestMapping(value = "/aop")
public class AopController {

    @RequestMapping(value = "/aopTest")
    public GenericJsonResult aopTest(Date currentDate) {
        System.out.println("aopTest" + currentDate);
        return new GenericJsonResult();
    }

    @RequestMapping(value = "/postTest")
    public GenericJsonResult postTest(@RequestParam("id") String id) {
        GenericJsonResult result = new GenericJsonResult();
        result.setContent(id);
        return result;
    }

    @PermissionAnnotation()
    @RequestMapping(value = "/check",produces = "application/json")
    public GenericJsonResult check(@RequestBody User user) {
        return new GenericJsonResult();
    }

    @LogAnnotation(moduleName = "aop测试",option = "切面")
    @RequestMapping(value = "/aopCustom")
    public GenericJsonResult aopCustom() {
        return new GenericJsonResult();
    }


    public static class User{

        private int id;
        private String name;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
